//
//  NearDetailViewController.m
//  wtshoppingcite
//
//  Created by TW on 14-10-18.
//  Copyright (c) 2014年 TW. All rights reserved.
//

#import "NearDetailViewController.h"
#import "BaseTableView.h"
#import "Macro.h"
#import "AppDelegate.h"
#import "AttrPriceLabel.h"
#import "JPScoreView.h"
#import "UIUtility.h"
#import "BuyViewController.h"
#import "EvaluateViewController.h"
#import "ShoppingCartViewController.h"
#import "EvaluateView.h"
#import "RegisterHelper.h"
#import "HDScrollview.h"

@interface NearDetailViewController ()<UITableViewDelegate,UITableViewDataSource,UIScrollViewDelegate,UITableViewEventsDelegate>
{
    BaseTableView *nearDetailTableView;
    HDScrollview *advScrollView;
    UIPageControl *pageControl;
}
@end

@implementation NearDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _shopArray = [[NSMutableArray alloc]initWithCapacity:1];
    _productArray = [[NSMutableArray alloc]initWithCapacity:1];
    
    self.view.backgroundColor = [UIColor whiteColor];
    [self setTitleView:@"商品详情"];
    
    nearDetailTableView = [[BaseTableView alloc]initWithFrame:CGRectMake(0, 0, kWidth, kHeight)];
    nearDetailTableView.dataSource = self;
    nearDetailTableView.delegate = self;
    nearDetailTableView.isNeedTorefresh = YES;
    nearDetailTableView.eventsDelegate = self;
    nearDetailTableView.isMore = YES;
    [self.view addSubview:nearDetailTableView];
    
    
    // Do any additional setup after loading the view.
}


#pragma mark getnearDetailWithData 商城详情
-(void)getnearDetailWithData:(NSString *)productId{
    
    NSMutableDictionary *listDic = [NSMutableDictionary dictionary];
    SetValueForKey(listDic, productId, @"productId");
    [NetWorkService byRequestWithAPIPrefix:kBaseAppUrl
                              andAPISuffix:kdetail
                             andHttpMethod:@"POST"
                             andParameters:listDic
                           andRequestCache:NO
                            andUseParamDic:YES
                       andPostDataEncoding:MKNKPostDataEncodingTypeJSON
                     andRequestFinishBlock:^(BYRequest *request, BYResponse *response) {
                         
                         if (response.isError) {
                             DLog(@"error %@",response.errorMessage);
                         }else{
                             NSDictionary *responseDic = request.responseJSON;
                             DLog(@"成功数据:%@",responseDic);
                             
                             NSDictionary *product = [responseDic objectForKey:@"product"];
                             NSDictionary *shop = [responseDic objectForKey:@"shop"];
                             
                             
                             
                             ShoppingDetailModel *shoppingDetailModel = [[ShoppingDetailModel alloc]initWithShoppingDetailInfo:shop];
                             _shoppingDetailModel = shoppingDetailModel;
                             [_shopArray addObject:shoppingDetailModel];
                             
                             
                             ProductDetailModel *productDetailModel = [[ProductDetailModel alloc]initWithShoppingDetailInfo:product];
                             _productDetailModel = productDetailModel;
                             [_productArray addObject:productDetailModel];
                             
                         }
                         
                         [nearDetailTableView reloadData];
                         
                     }];
    
}


-(void)ShoppingCartAction:(UIButton *)button{
    
    //[RegisterHelper shareHelper].budgeNum = 0;
    [_imageView removeFromSuperview];
    
    ShoppingCartViewController *shoppingCartVC = [[ShoppingCartViewController alloc]init];
    shoppingCartVC.shoppingModel = self.shoppingModel;
    [self.navigationController pushViewController:shoppingCartVC animated:YES];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [_imageView removeFromSuperview];
    [self getnearDetailWithData:self.shoppingModel.sid];
    ;
}


- (void)viewWillDisappear:(BOOL)animated
{

    [super viewWillDisappear:animated];
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    NSString* inclusiveDetails = self.productDetailModel.inclusiveDetails;
    NSString* consumeTips = self.productDetailModel.consumeTips;
    if(inclusiveDetails.length == 0 && consumeTips.length == 0)
        return 8;
    else if(inclusiveDetails.length == 0 && consumeTips.length != 0){
        return 10;
    }else if(inclusiveDetails.length != 0 && consumeTips.length == 0)
        return 10;
    return 12;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row <= 4) {
    
        UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"shareCellIdentitfer"];
  
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"shareCellIdentitfer"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    [[cell.contentView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];

    if (indexPath.row == 0) {
        CGFloat w = kWidth;
        CGFloat h = 200;
        
        NSMutableArray *ImageArr = [NSMutableArray arrayWithCapacity:1];
        if (self.productDetailModel.imgPaths.count == 0) {
           [ImageArr addObject:[UIImage imageNamed:@"imagePath_default"]];
        }else{
            
            [ImageArr addObjectsFromArray:self.productDetailModel.imgPaths];
        }
       
        
        UIScrollView *mainScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kWidth, 200)];
        mainScrollView.showsHorizontalScrollIndicator = NO;
        mainScrollView.showsVerticalScrollIndicator = NO;
        mainScrollView.backgroundColor = COLOR_RGB(228, 229, 228);
        mainScrollView.contentSize = CGSizeMake(ImageArr.count * w, 0);
        mainScrollView.showsHorizontalScrollIndicator = NO;
        mainScrollView.pagingEnabled = YES;
        mainScrollView.delegate = self;
        [cell.contentView addSubview:mainScrollView];
        
        pageControl = [[UIPageControl alloc] init];
        pageControl.frame = CGRectMake((kWidth -120)/2, 200-20, 120, 10);
        pageControl.numberOfPages = ImageArr.count;
        pageControl.enabled = NO;
        pageControl.currentPage = 0;
        [cell.contentView addSubview:pageControl];

        for (int i = 0; i< ImageArr.count; i++) {
            UIImageView *imageView = [[UIImageView alloc] init];
            imageView.frame = CGRectMake(i * w, 0, w, h);
            // 2.设置图片
            NSString *imgName = [NSString stringWithFormat:@"%@", ImageArr[i]];
            imageView.image = [UIImage imageNamed:imgName];
            [imageView setImageWithURL:[NSURL URLWithString:imgName] placeholderImage:[UIImage imageNamed:@"imagePath_default"]];
            [mainScrollView addSubview:imageView];
            
        }

        
        UIImageView *iconImage = [[UIImageView alloc]initWithFrame:CGRectMake(20, mainScrollView.bottom + 35, 8, 8)];
        iconImage.image = [UIImage imageNamed:@"money_code"];
        [cell.contentView addSubview:iconImage];
        
        
        UILabel *oPirceLabel = [[UILabel alloc]initWithFrame:CGRectMake(iconImage.right +5, mainScrollView.bottom + 15, 100, 45)];
        oPirceLabel.text = self.shoppingModel.nPrice;
        [cell.contentView addSubview:oPirceLabel];
        oPirceLabel.font = [UIFont systemFontOfSize:20.0f];
        oPirceLabel.backgroundColor = [UIColor clearColor];
        oPirceLabel.textColor = MAIN_BLUE_COLOR;
        
        CGSize size = [self.shoppingModel.nPrice  getSizeOfStringFontSize:20.0 constroSize:CGSizeMake(60, MAXFLOAT)];
        oPirceLabel.width = size.width;
   
        AttrPriceLabel *nPriceLabel = [[AttrPriceLabel alloc]initWithFrame:CGRectMake( oPirceLabel.right+10,  mainScrollView.bottom + 30, 60, 20)];
        [cell.contentView addSubview:nPriceLabel];
        nPriceLabel.textAlignment = NSTextAlignmentCenter;
        nPriceLabel.font = [UIFont systemFontOfSize:12.0f];
        nPriceLabel.backgroundColor = [UIColor clearColor];
        [nPriceLabel setPriceType:2 text:self.shoppingModel.oPrice];

        
        UIButton *buyButton = [[UIButton alloc]initWithFrame:CGRectMake(kWidth - 70 , mainScrollView.bottom + 10,  80, 35)];
        buyButton.right =kWidth - 10;
        [buyButton setTitle:@"立即购买" forState:UIControlStateNormal];
        [buyButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [buyButton setBackgroundImage:[UIImage imageNamed:@"register_select"] forState:UIControlStateNormal];
        [buyButton addTarget:self action:@selector(buyButtonAction) forControlEvents:UIControlEventTouchUpInside];
        [buyButton setTitleColor: [UIColor whiteColor] forState:UIControlStateNormal];
        [buyButton setFont:[UIFont systemFontOfSize:13.0f]];
        [cell.contentView addSubview:buyButton];
        
//        UIButton *joinButton = [[UIButton alloc]initWithFrame:CGRectMake(kWidth - 70 , mainScrollView.bottom + 10, 80, 35)];
//        joinButton.right = buyButton.left - 5;
//        [joinButton setFont:[UIFont systemFontOfSize:12.0f]];
//        [joinButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//        [joinButton setBackgroundColor:UIColorFromRGB(0x008cd6)];
//        [joinButton setTitle:@"加入购物车" forState:UIControlStateNormal];
//        [joinButton addTarget:self action:@selector(joinButtonAction) forControlEvents:UIControlEventTouchUpInside];
//        [joinButton setTitleColor: [UIColor whiteColor] forState:UIControlStateNormal];
//        [cell.contentView addSubview:joinButton];
        
    }else if(indexPath.row == 1){
        
        UIView *separateView = [[UIView alloc]init];
        separateView.frame = CGRectMake(0,0, kWidth, 10);
        separateView.backgroundColor = UIColorFromRGB(0x9fa0a0);
        separateView.alpha =0.2;
        [cell.contentView addSubview:separateView];
        
        UILabel *titleLabel =[self createLabelWithFrame:CGRectMake(separateView.bottom + 5, separateView.bottom + 5, kWidth - 20, 20) text:@"" font:15.0f textAli:NSTextAlignmentLeft textColor:MAIN_BLACK_COLOR];
        titleLabel.text = self.shoppingModel.title;
        [cell.contentView addSubview:titleLabel];
        
        UILabel *subTitleLabel =[self createLabelWithFrame:CGRectMake(titleLabel.left, titleLabel.bottom+5, kWidth - 20, 60) text:@"" font:13.0f textAli:NSTextAlignmentLeft textColor:UIColorFromRGB(0x9fa0a0)];
        subTitleLabel.numberOfLines = 0;
        subTitleLabel.text = self.shoppingModel.subTitle;
        [cell.contentView addSubview:subTitleLabel];
        
        CGFloat height = [UIUtility getHeightOfString:subTitleLabel.text withFont:[UIFont systemFontOfSize:13.0f] withWidth:300];
        subTitleLabel.height = height;
        
    }else if (indexPath.row == 2){
        
        UIImageView *iconImage = [[UIImageView alloc]initWithFrame:CGRectMake(15, 10, 20, 20)];
        iconImage.image = [UIImage imageNamed:@"near_sale"];
        [cell.contentView addSubview:iconImage];
        
        
        UILabel *saleLabel = [[UILabel alloc]initWithFrame:CGRectMake(iconImage.right+3, iconImage.top, 40, 20)];
        saleLabel.text =@"已售";
        [cell.contentView addSubview:saleLabel];
        saleLabel.font = [UIFont systemFontOfSize:13.0f];
        saleLabel.backgroundColor = [UIColor clearColor];
        saleLabel.textColor =  UIColorFromRGB(0x9fa0a0);
        
        UILabel *saleTextLabel = [[UILabel alloc]initWithFrame:CGRectMake(saleLabel.right -5, iconImage.top, 40, 20)];
        saleTextLabel.text = self.shoppingModel.saledCount ;
        [cell.contentView addSubview:saleTextLabel];
        saleTextLabel.font = [UIFont systemFontOfSize:13.0f];
        saleTextLabel.backgroundColor = [UIColor clearColor];
        saleTextLabel.textColor =  UIColorFromRGB(0x9fa0a0);
        
        
        UIImageView *iconView = [[UIImageView alloc]initWithFrame:CGRectMake(kWidth/2 + 15, 10, 20, 20)];
        iconView.image = [UIImage imageNamed:@"near_time"];
        [cell.contentView addSubview:iconView];
        
        NSString *limitTime = @"剩余6天5小时39分16秒";
        NSArray *timeArray = [self.shoppingModel.limitTime componentsSeparatedByString:@":"];
        NSString *limitString = @"";
        if (timeArray.count == 3) {
            limitString = [NSString stringWithFormat:@"剩余%d天%d小时%d分", [timeArray[0] integerValue], [timeArray[1] integerValue], [timeArray[2] integerValue]];
        }else if (timeArray.count == 2) {
            limitString = [NSString stringWithFormat:@"剩余%d小时%d分", [timeArray[0] integerValue], [timeArray[1] integerValue]];
        } else {
            limitString = [NSString stringWithFormat:@"剩余%d分", [timeArray[0] integerValue]];
        }
        limitTime = limitString;
        
        UILabel *textLabel = [[UILabel alloc]initWithFrame:CGRectMake(iconView.right, iconImage.top, 120, 20)];
        textLabel.text = limitTime;
        [cell.contentView addSubview:textLabel];
        textLabel.font = [UIFont systemFontOfSize:13.0f];
        textLabel.backgroundColor = [UIColor clearColor];
        textLabel.textColor =  UIColorFromRGB(0x9fa0a0);
        
        
        UIView *separateView = [[UIView alloc]init];
        separateView.frame = CGRectMake(0,55-10, kWidth, 10);
        separateView.backgroundColor = UIColorFromRGB(0x9fa0a0);
        separateView.alpha =0.2;
        [cell.contentView addSubview:separateView];
        
    }else if (indexPath.row == 3){
        
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        
        UILabel *scoreLabel = [[UILabel alloc]initWithFrame:CGRectMake(kWidth/2 -100/2, 10, 100, 20)];
        scoreLabel.text = @"查看全部评价";
        [cell.contentView addSubview:scoreLabel];
        scoreLabel.font = [UIFont systemFontOfSize:15.0f];
        scoreLabel.backgroundColor = [UIColor clearColor];
        scoreLabel.textColor = MAIN_BLUE_COLOR;
    
    }else if(indexPath.row == 4){
        
        NSString *descStr = self.shoppingDetailModel.prodQuality;
        if (descStr == nil) {
            descStr = @"";
        }else{
            descStr = [NSString stringWithFormat:@"%@分",self.shoppingDetailModel.prodQuality];
        }
        
        NSString *servStr = self.shoppingDetailModel.serviceAttitude;
        if (servStr == nil) {
            servStr = @"";
        }else{
            servStr = [NSString stringWithFormat:@"%@分",self.shoppingDetailModel.serviceAttitude];
        }
        
        NSString *delivStr = self.shoppingDetailModel.deliverySpeed;
        if (delivStr == nil) {
            delivStr = @"";
        }else{
            delivStr = [NSString stringWithFormat:@"%@分",self.shoppingDetailModel.deliverySpeed];
        }
        
        EvaluateView *evaluateView = [[EvaluateView alloc]initWithFrame:CGRectMake(0, 0, kWidth, 40)];
        [evaluateView initWithLineItemNames:@[@"描述相符",@"服务态度",@"发货速度"] scoreNames:@[descStr,servStr,delivStr]];
        [cell.contentView addSubview:evaluateView];
        
        UIView *separateView1 = [[UIView alloc]init];
        separateView1.frame = CGRectMake(0,50-10, kWidth, 10);
        separateView1.backgroundColor = UIColorFromRGB(0x9fa0a0);
        separateView1.alpha =0.2;
        [cell.contentView addSubview:separateView1];
        
      }
        return cell;
    }else if(indexPath.row >4 && indexPath.row <= 9){
        
        UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"shareCellIdentitfer2"];
        
        if (cell == nil) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"shareCellIdentitfer2"];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        [[cell.contentView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];

        if(indexPath.row == 5){
            
            UILabel *titleLabel =[self createLabelWithFrame:CGRectMake(15, 10, 160, 20) text:@"" font:15.0f textAli:NSTextAlignmentLeft textColor:MAIN_BLACK_COLOR];
            titleLabel.text = @"商家信息";
            [cell.contentView addSubview:titleLabel];
            
        }else if(indexPath.row == 6){
            
            UILabel *titleLabel =[self createLabelWithFrame:CGRectMake(15, 15, kWidth-50, 20) text:@"" font:15.0f textAli:NSTextAlignmentLeft textColor:MAIN_BLACK_COLOR];
            titleLabel.text = self.shoppingDetailModel.shopName;
            [cell.contentView addSubview:titleLabel];
            
            UILabel *distanceLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 15, 40, 20)];
            distanceLabel.text = [NSString stringWithFormat:@"%.fm",[self.shoppingModel.distance floatValue]];
            distanceLabel.right = kWidth - 10;
            distanceLabel.textAlignment = NSTextAlignmentRight;
            [cell.contentView addSubview:distanceLabel];
            distanceLabel.font = [UIFont systemFontOfSize:13.0f];
            distanceLabel.backgroundColor = [UIColor clearColor];
            distanceLabel.textColor =  UIColorFromRGB(0x9fa0a0);
            
            UILabel *addressLabel =[self createLabelWithFrame:CGRectMake(titleLabel.left, titleLabel.bottom, kWidth-20, 60) text:@"" font:14.0f textAli:NSTextAlignmentLeft textColor:UIColorFromRGB(0x9fa0a0)];
            addressLabel.text = self.shoppingDetailModel.addr;
            addressLabel.numberOfLines = 0;
            [cell.contentView addSubview:addressLabel];
            
        }else if(indexPath.row == 7){
            
            UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake((kWidth-80)/2, (45-20)/2, 80, 20)];
            [button setImage:[UIImage imageNamed:@"register_tel"] forState:UIControlStateNormal];
            [button addTarget:self action:@selector(shoppingTelAction) forControlEvents:UIControlEventTouchUpInside];
            [button setTitleColor:UIColorFromRGB(0x9fa0a0) forState:UIControlStateNormal];
            [button setFont:[UIFont systemFontOfSize:14.f]];
            [button setTitle:@"拨打电话" forState:UIControlStateNormal];
            [cell.contentView addSubview:button];
            
        }else if(indexPath.row == 8){
            
            UIView *separateView = [[UIView alloc]init];
            separateView.frame = CGRectMake(0,0, kWidth, 10);
            separateView.backgroundColor = UIColorFromRGB(0x9fa0a0);
            separateView.alpha =0.2;
            [cell.contentView addSubview:separateView];
            
            UILabel *titleLabel =[[UILabel alloc]initWithFrame:CGRectMake(15, separateView.bottom + 15, 160, 20)];
            titleLabel.text = @"套餐内容";
            [cell.contentView addSubview:titleLabel];
            
            
            
        }else if(indexPath.row == 9){
            
            UILabel *titleLabel =[[UILabel alloc]initWithFrame:CGRectMake(15, 10, kWidth - 20, 290)];
            titleLabel.numberOfLines = 0;
            titleLabel.text = self.productDetailModel.inclusiveDetails;
            titleLabel.font = [UIFont systemFontOfSize:15.0f];
            titleLabel.backgroundColor = [UIColor clearColor];
            titleLabel.textColor =  UIColorFromRGB(0x9fa0a0);
            
//            CGFloat weith = [UIUtility getLabelWidthOfText:titleLabel.text andFont:[UIFont systemFontOfSize:15.0f]];
            CGFloat height = [UIUtility getHeightOfString:titleLabel.text withFont:[UIFont systemFontOfSize:15.0f] withWidth:300];
            titleLabel.height = height;
            [cell.contentView addSubview:titleLabel];
            
        }
        
        return cell;

        
    }else{
        
        UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"shareCellIdentitfer3"];
        
        if (cell == nil) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"shareCellIdentitfer3"];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        [[cell.contentView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];

       if(indexPath.row == 10){
           
            UIView *separateView = [[UIView alloc]init];
            separateView.frame = CGRectMake(0,0, kWidth, 10);
            separateView.backgroundColor = UIColorFromRGB(0x9fa0a0);
            separateView.alpha =0.2;
            [cell.contentView addSubview:separateView];
            
            UILabel *titleLabel =[[UILabel alloc]initWithFrame:CGRectMake(15, separateView.bottom + 15, 160, 20)];
            titleLabel.text = @"消费提示";
            [cell.contentView addSubview:titleLabel];
            
        }else if(indexPath.row == 11){
            UILabel *titleLabel =[[UILabel alloc]initWithFrame:CGRectMake(15, 10, kWidth - 20, 290)];
            titleLabel.numberOfLines = 0;
            titleLabel.text = self.productDetailModel.consumeTips;
            titleLabel.font = [UIFont systemFontOfSize:15.0f];
            titleLabel.backgroundColor = [UIColor clearColor];
            titleLabel.textColor =  UIColorFromRGB(0x9fa0a0);
            [cell.contentView addSubview:titleLabel];
            
            CGFloat height = [UIUtility getHeightOfString:titleLabel.text withFont:[UIFont systemFontOfSize:15.0f] withWidth:300];
            titleLabel.height = height;
        }
        return cell;
    }
}


#pragma mark telAction
-(void)shoppingTelAction{
    
    NSString *str = [NSString stringWithFormat:@"tel://%@",self.shoppingDetailModel.tel];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}

#pragma mark ==========UIScrollViewDelegate============
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
        int page = scrollView.contentOffset.x / scrollView.frame.size.width;
        //
        NSLog(@"%d", page);
        // 设置页码
        pageControl.currentPage = page;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 0) {
        return 260;
    }else if (indexPath.row == 1){
        NSString* content = self.shoppingModel.subTitle;
        CGFloat height = [UIUtility getHeightOfString:content withFont:[UIFont systemFontOfSize:15.0f] withWidth:300];
        return height + 50;
    }else if(indexPath.row == 2){
        return 55;
    }else if(indexPath.row == 3){
        return 40;
    }else if(indexPath.row == 4){
        return 50 ;
    }else if(indexPath.row == 5){
        return 40;
    }else if(indexPath.row == 6){
        return 90;
    }else if(indexPath.row == 7){
        NSString* inclusiveDetails = self.productDetailModel.inclusiveDetails;
        NSString* consumeTips = self.productDetailModel.consumeTips;
        if(inclusiveDetails.length == 0 || consumeTips.length == 0){
            return 45+50;
        }
        return 45;
    }else if(indexPath.row == 8){
        NSString* inclusiveDetails = self.productDetailModel.inclusiveDetails;
        if(inclusiveDetails.length == 0)
            return 0;
        return 60;
    }else if(indexPath.row == 9){
        NSString* inclusiveDetails = self.productDetailModel.inclusiveDetails;
        CGFloat height = [UIUtility getHeightOfString:inclusiveDetails withFont:[UIFont systemFontOfSize:15.0f] withWidth:300];
        return height+20;
    }else if(indexPath.row == 10){
        NSString* consumeTips = self.productDetailModel.consumeTips;
        if(consumeTips.length == 0)
            return 0;
        return 60;
    }else if(indexPath.row == 11){
        NSString* consumeTips = self.productDetailModel.consumeTips;
        CGFloat height = [UIUtility getHeightOfString:consumeTips withFont:[UIFont systemFontOfSize:15.0f] withWidth:300];
        return height+50;
    }else{
        return 0;
    }
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 3) {
        
        EvaluateViewController *evaluateVC = [[EvaluateViewController alloc]init];
        evaluateVC.hidesBottomBarWhenPushed = YES;
        evaluateVC.productId = self.shoppingModel.sid;
        [self.navigationController pushViewController:evaluateVC animated:YES];
        
    }
    
}

#pragma mark buyButtonAction
-(void)buyButtonAction{
    if ([APP_DELEGATE isLogin]) {
  
    BuyViewController *buyVC = [[BuyViewController alloc]init];
    buyVC.hidesBottomBarWhenPushed = YES;
    buyVC.shoppingModel = self.shoppingModel;
    [self.navigationController pushViewController:buyVC animated:YES];
        
    }else{
         [self showToastMessage:@"请先登录..."];
        [APP_DELEGATE pushLoginViewControllerWithStoryBoardIdentifier:@"LoginViewController" pushIn:self];
    }
}

#pragma mark joinButtonAction
-(void)joinButtonAction{
    
    NSString *shoppingSid = self.shoppingModel.sid;
    [[RegisterHelper shareHelper].purchaseArray  addObject:shoppingSid];
     _budgeNum++;
    [[RegisterHelper shareHelper] setBudgeNum:[NSString stringWithFormat:@"%d",_budgeNum]];
    _budgeNumLabel.text =[RegisterHelper shareHelper].budgeNum;
    [_button addSubview:_imageView];
    
    NSMutableDictionary* shopCarNumbers = [[RegisterHelper shareHelper] shopCarNumbers];
    NSString* key = shoppingSid;
    NSString* value = shopCarNumbers[key];
    int num;
    if(value.length == 0 || value.integerValue == 0 || value == nil){
        num = 0;
    }else{
        num = value.intValue;
    }
    num++;
    [shopCarNumbers setObject:[NSString stringWithFormat:@"%d",num] forKey:key];
    [[RegisterHelper shareHelper] setShopCarNumbers:shopCarNumbers];

}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
